package com.hue.springbootjwt.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.SetOperations;
import org.springframework.stereotype.Component;

/**
 * 操作redis的工具类
 */
@Component
public class RedisUtils {
    @Autowired
    private RedisTemplate<String,String> redisTemplate;

    /**
     * 将jwt令牌保存在redis中
     * @param jwt
     */
    public void login(String jwt){
        //将token存到redis中
        SetOperations<String, String> ops = redisTemplate.opsForSet();
        ops.add("users", jwt);
        ops.members("users");
    }
}
